#ifndef __GLOBALMEM_H__
#define __GLOBALMEM_H__

#ifndef PAGE_SIZE
#define PAGE_SIZE (4*1024)
#endif
#define BUF_SIZE (16*PAGE_SIZE)

#define MEM_SIZE BUF_SIZE
#define MAX_USER 4

enum ud_status
{
    UD_BUSY,
    UD_READY
};

struct user_private_data
{
    struct mydev_dev * dev;
    /* other data you like */
};

struct mydev_dev {
    int             devno;
    struct cdev     cdev;
    struct class *  class;
    unsigned char   mem[MEM_SIZE];
    int user_cnt;
    // for block-io
    wait_queue_head_t r_wait;
    spinlock_t spinlock;
    int status;
    // 为了实现每一个用户在读写时能够拥有自己的数据
    //struct user_private_data udata;
};

#define DEV_NAME             "mydev"
#define GM_IOCTL_MAGIC  'g'
/*! \enum gm_ioctl_cmd_num
 *
 *  Detailed description
 */
enum gm_ioctl_cmd_num {
    GM_CLEAR
};
#define GM_IOCTL_CMD_CLEAR  _IO(GM_IOCTL_MAGIC, GM_CLEAR)

#define CONFIG_ENABLE_LOG   1
#define CONFIG_ENABLE_DEBUG 1
#define CONFIG_ENABLE_ERROR 1

#define sc_debug(fmt, arg...)                     \
    do{                                         \
         if(CONFIG_ENABLE_DEBUG){                 \
         printk("D[%s] :"fmt, __func__, ##arg);  \
     }else{ }                                   \
     }while(0)

#define sc_info(fmt, arg...)                     \
    do{                                         \
         if(CONFIG_ENABLE_LOG){                 \
         printk("I[%s] :"fmt, __func__, ##arg);  \
     }else{ }                                   \
     }while(0)

#define sc_err(fmt, arg...)                     \
    do{                                         \
         if(CONFIG_ENABLE_ERROR){                 \
         printk("E[%s] :"fmt, __func__, ##arg);  \
     }else{ }                                   \
     }while(0)

#endif /* ifndef __GLOBALMEM_H__
 */
